﻿#pragma once

#include <filesystem>
#include <fstream>
#include <string>
#include <vector>
#include "Book.h"
#include "BorrowingRecord.h"

class FileHandler
{
private:
	std::filesystem::path booksFilePath, recordsFilePath;

public:
    FileHandler(const std::filesystem::path& booksPath, const std::filesystem::path& recordsPath);
	
	void loadData(std::vector<Book>& books, std::vector<BorrowingRecord>& borrowingRecords);
	void saveData(std::vector<Book>& books, std::vector<BorrowingRecord>& borrowingRecords);

private:
	static void readString(std::ifstream& ifs, std::string& str);
	static void writeString(std::ofstream& ofs, const std::string& str);
};

